import logging

# 创建Logger对象
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

# 创建控制台输出的StreamHandler
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.DEBUG)
console_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
logger.addHandler(console_handler)

# 创建文件输出的FileHandler
file_handler = logging.FileHandler('app.log', encoding='utf-8')
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
logger.addHandler(file_handler)

logger.debug("这是一条包含中文的调试日志")
logger.info("这是一条包含中文的信息日志")
